package com.cniao5.myapplication.component.splash

import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.cniao5.myapplication.R
import com.cniao5.myapplication.activity.BaseLogicActivity
import com.cniao5.superui.date.SuperDateUtil

class SplashActivity : BaseLogicActivity() {
    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_splash)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

//        //设置版本年份
//        val currentYear = SuperDateUtil.currentYear()
//        val copyrightView = findViewById<TextView>(R.id.copyright)
//        copyrightView.text = "Copyright @ $currentYear Ixuea. ALL Rights Reserved"
    }

    override fun initViews() {
        super.initViews()
    }

    override fun initDatum() {
        super.initDatum()

        //设置版本年份
        val currentYear = SuperDateUtil.currentYear()
        val copyrightView = findViewById<TextView>(R.id.copyright)
        copyrightView.text = getString(R.string.copyright, currentYear)

        showTermsServiceAgreementDialog()
    }

    private fun showTermsServiceAgreementDialog() {
//        TermServiceDialogFragment.show(supportFragmentManager, object : View.OnClickListener {
//            override fun onClick(p0: View?) {
//                Log.d(TAG, "primary onClick")
//            }
//
//        })
        TermServiceDialogFragment.show(supportFragmentManager
        ) { Log.d(TAG, "primary onClick") }
    }

    companion object {
        const val TAG = "SplashActivity"
    }
}